#include <stdio.h>
#include <execinfo.h>
#include <stdlib.h>

#define SIZE 1024
void show_backtrace()
{
        int nptrs;
        void *buffer[SIZE];
        char **strings;
        nptrs = backtrace(buffer, SIZE);
        strings = backtrace_symbols(buffer, nptrs);
        if (strings != NULL){
                int i;
                for (i = 0; i < nptrs; ++i)
                        printf("%s\n",strings[i]);
                free(strings);
        }
}

void test_bt(void)
{
	printf("%s:%d\n", __func__, __LINE__);
	show_backtrace();
}

int main(int argc, char **argv)
{
	test_bt();
	return 0;
}
	
